package com.jpress.model;

import java.util.Calendar;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

@Entity
public class Admin extends Usuario {
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="dono")
	private List<Blog> blogs;
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="autor")
	private List<Post> posts;
	
	public Admin() {
		super();
	}

	public Admin(String email, String senha, String nome, Calendar dataCadastro) {
		super(email, senha, nome, dataCadastro);
	}

	public List<Blog> getBlogs() {
		return blogs;
	}

	public void setBlogs(List<Blog> blogs) {
		this.blogs = blogs;
	}
	
	public void adicionarBlog(Blog blog){
		this.blogs.add(blog);
	}

	public List<Post> getPosts() {
		return posts;
	}

	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}
	
	public void adicionarPost(Post post){
		this.posts.add(post);
	}
	
	@Override
	public Boolean isAdmin() {
		return true;
	}

	@Override
	public String toString() {
		return "Admin [blogs=" + blogs + ", posts=" + posts + "]";
	}
}
